//
//  ReadPDFViewController.m
//  SBooks
//
//  Created by shansander on 2016/11/14.
//  Copyright © 2016年 shansander. All rights reserved.
//

#import "ReadPDFViewController.h"
#import "UIImage+PDF.h"
#import "SDCycleScrollerView.h"
#import "CycleImageView.h"

@interface ReadPDFViewController ()<SDCycleDelegate>
{
}
@property (nonatomic, weak) IBOutlet SDCycleScrollerView * cycleView;

@end

@implementation ReadPDFViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"this is pdf view");
    [UIImage setShouldCacheOnDisk:YES];
    self.cycleView.delegate = self;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self.cycleView reloadData];
}


#pragma mark - SDCycleDelegate

- (SDCycleView *)cycleView:(SDCycleScrollerView *)cycleScrollerView cycleViewForRow:(NSInteger)row
{
    CycleImageView * view = [[CycleImageView alloc] init];
    NSInteger page = row + 1;
    NSLog(@" -->%ld",(long)page);
    UIImage * image = [UIImage imageWithPDFURL:[NSURL fileURLWithPath:self.theFilePath] atSize:self.cycleView.bounds.size atPage:page];
    [view displayImage:image];
    return view;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
